/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

/**
 *
 * @author memozac
 */
@Entity
public class Person implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idPerson;

   

    public enum Profile{DESIGNER,ADMINISTRATOR,NORMAL_USER,DATA_MANAGER};

    @Enumerated
    private Profile profile;

    @OneToMany
    private List<Note> notes;

    

    @Column(columnDefinition="text")
    private String username;
    @Column(columnDefinition="text")
    private String password;
    @Column(columnDefinition="text")
    private String email;
    @Column(columnDefinition="text")
    private String name;

    @ManyToMany(targetEntity=ScoreDomain.class)
    @JoinTable(name="PersonScoreDomain",
    joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idScoreDomain"))
    private Collection<ScoreDomain> scoreDomains;

    @ManyToMany(targetEntity=ActionPlan.class)
    @JoinTable(name="ActionPlanPerson",
    joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idActionPlan"))
    private Collection<ActionPlan> actionPlans;

    /*@ManyToMany(targetEntity=ScoreCard.class)
    @JoinTable(name="PersonScoreCard",
    joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard"))*/
    @OneToMany
    private Collection<ScoreCard> scoreCards;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Note> getNotes() {
        return notes;
    }

    public void setNotes(List<Note> notes) {
        this.notes = notes;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Collection<ScoreCard> getScoreCards() {
        return scoreCards;
    }

    public void setScoreCards(Collection<ScoreCard> scoreCards) {
        this.scoreCards = scoreCards;
    }

    public Collection<ScoreDomain> getScoreDomains() {
        return scoreDomains;
    }

    public void setScoreDomains(Collection<ScoreDomain> scoreDomains) {
        this.scoreDomains = scoreDomains;
    }

     /**
     * @return the actionPlans
     */
    public Collection<ActionPlan> getActionPlans() {
        return actionPlans;
    }

    /**
     * @param actionPlans the actionPlans to set
     */
    public void setActionPlans(Collection<ActionPlan> actionPlans) {
        this.actionPlans = actionPlans;
    }

    public Long getIdPerson() {
        return idPerson;
    }

    public Profile getProfile() {
        return profile;
    }

    public void setProfile(Profile profile) {
        this.profile = profile;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPerson != null ? idPerson.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Person)) {
            return false;
        }
        Person other = (Person) object;
        if ((this.idPerson == null && other.idPerson != null) || (this.idPerson != null && !this.idPerson.equals(other.idPerson))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.Person[id=" + idPerson + "]";
    }

}//ends of class
